<template>
  <div class="cart-control-wrapper">
    <transition name="move">
      <div class="cartcontrol">
        <div class="cart-decrease" v-show="foods.count" @click.stop="decrese">
          <i class="cubeic-remove"></i>
        </div>
      </div>
    </transition>
    <div class="cart-count" v-show="foods.count">{{ foods.count }}</div>
    <div class="cart-add" @click.stop="addNumFn">
      <i class="cubeic-add"></i>
    </div>
  </div>
</template>

<script>
const EVEND_ADD = 'add';
export default {
  name: 'goods',
  props: {
    foods: Object,
  },
  data() {
    return { count: 0 };
  },
  methods: {
    addNumFn(event) {
      if (!this.foods.count) {
        this.$set(this.foods, 'count', 1);
      } else {
        this.foods.count++;
      }
      this.$emit('retCon', this.foods);
      this.$emit(EVEND_ADD, event.target);
    },

    decrese() {
      if (this.foods.count) {
        this.foods.count--;
      }
      this.$emit('retCon', this.foods);
    },
  },
  created() {},
};
</script>

<style lang="stylus" scoped>
.scroll-ele {
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #fff;
}

.goods {
  position: relative;
  text-align: left;
  height: 100%;

  >>> .cube-scroll-list-wrapper {
    width: 100%;
    text-align: left;
  }

  .cube-scroll-nav-main {
    display: flex;
  }

  >>> .cube-scroll-nav-bar {
    width: 80px;
    white-space: normal;
    overflow: hidden;
  }

  >>> .cube-scroll-nav-bar-item {
    padding: 0 10px;
    display: flex;
    align-items: center;
    height: 40px;
    line-height: 1.5;
    font-size: 12px;
    background: #f3f5f7;

    .text {
      flex: 1;
      position: relative;
    }

    .num {
      position: absolute;
      right: -8px;
      top: -10px;
    }

    .support-ico {
      display: inline-block;
      vertical-align: top;
      margin-right: 4px;
    }
  }

  >>> .cube-scroll-nav-bar-item_active {
    background: $color-white;
    color: $color-dark-grey;
  }

  >>> .cube-scroll-nav-panel-title {
    padding-left: 14px;
    height: 30px;
    line-height: 30px;
    border-left: 2px solid #666;
    font-size: 14px;
    color: #666;
    background: #f3f5f7;
    width: 100%;
  }

  >>> .cube-scroll-nav-panel {
    width: 100%;
    position: relative;

    ul {
      flex: 3;

      li {
        margin: 18px;
        padding-bottom: 18px;
        position: relative;

        a {
          display: flex;
        }

        .icon {
          width: 54px;
          height: 42px;
          flex: 0 0 57px;
          margin-right: 10px;

          img {
            width: 100%;
          }
        }

        .content {
          flex: 1;

          .name {
            margin: 2px 0 8px 0;
            height: 14px;
            line-height: 14px;
            font-size: 12px;
            color: #666;
          }

          .desc, .extra {
            line-height: 10px;
            font-size: 12px;
            color: #999;
          }

          .desc {
            line-height: 12px;
            margin-bottom: 8px;
          }

          .extra {
            .count {
              margin-right: 12px;
            }
          }

          .price {
            font-weight: 700;
            line-height: 24px;

            .now {
              margin-right: 8px;
              font-size: 14px;
              color: red;
            }

            .old {
              text-decoration: line-through;
              font-size: 12px;
              color: #999;
            }
          }
        }
      }
    }
  }

  >>>.foods-item {
    position: relative;
  }

  >>>.cart-control-wrapper {
    bottom: 12px;
    position: absolute;
    right: 0;
    font-size: 24px;
    display: flex;
    justify-content: space-between;
  }
}

>>>.cart-decrease, >>>.cart-count, >>>.cart-add {
  color: #00a0dc;
  display: inline-block;
  font-size: 24px;
  line-height: 24px;
  padding: 4px;
  flex: 1;
  transition: all 0.4s linear;
  transform: rotate(0);
}

>>>.cart-count {
  font-size: 14px;
  color: #999;
  vertical-align: middle;
}

>>>.cube-scroll-nav-bar-item_active {
  color: #666;
}

>>> .cube-scroll-nav-panel-title {
  position: absolute;
  top: 0;
  left: 0;
}


>>>.cube-sticky-ele {
  height: 30px;
}

.scroll-nav-wrapper {
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
  bottom: 48px;
}

>>>.cube-sticky-fixed {
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 1;
}
</style>
